package com.download.backstage.controller;

import com.download.web.entity.SysSponsor;
import com.download.web.service.ISponsorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/backstage/sponsor")
public class SysSponsorController {
    @Autowired
    private ISponsorService sponsorService;

    @RequestMapping("/toSponsor")
    public String toSponsor(Model model){
        SysSponsor sponsor=sponsorService.selectById(1);
        model.addAttribute("sponsor",sponsor);
        return "backstage/zanzhu";
    }

    @RequestMapping("/updateSponsor")
    @ResponseBody
    public String updateSponsor(@ModelAttribute  SysSponsor sponsor){
        int count=sponsorService.updateSponsor(sponsor);
        if(count>0){
            return "修改成功";
        }else{
            return "修改失败";
        }
    }
}
